package pe.sonrisas.tools.view;

import Complementos.Conexion_BD;
import Complementos.Validar;
import java.awt.event.KeyEvent;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;


public class frmMantenerTecnicoDental extends javax.swing.JFrame {
Validar validar=new Validar();
    ArrayList<ArrayList> listado = new ArrayList<ArrayList>();
    
    /* CONSTRUCTOR - INICIALIZACION DE VALORES */
public frmMantenerTecnicoDental() {
        initComponents(); // UBICA TODOS LOS COMPONENTES VISUALES EN EL FORMULARIO
        txtBusqueda.requestFocus();
        cargarDepartamentos();
        
        // FORZAR QUE ELIJA A LIMA COMO DISTRITO PREDETERMINADO
        comboDepto.setSelectedItem("LIMA");    
        
        
        
    }
    
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        btnBuscar = new javax.swing.JButton();
        comboBuscar = new javax.swing.JComboBox();
        txtBusqueda = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblTecnico = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        panelOdontologo = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txtApellidoPaterno = new javax.swing.JTextField();
        txtApellidoMaterno = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        txtNombres = new javax.swing.JTextField();
        txtDni = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtDireccion = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtTel = new javax.swing.JTextField();
        txtCelular = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        txtNacionalidad = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        comboDepto = new javax.swing.JComboBox();
        comboProvincia = new javax.swing.JComboBox();
        comboDistrito = new javax.swing.JComboBox();
        comboFecha = new datechooser.beans.DateChooserCombo();
        txtEdad = new javax.swing.JTextField();
        jPanel3 = new javax.swing.JPanel();
        rbtMasculino = new javax.swing.JRadioButton();
        rbtFemenino = new javax.swing.JRadioButton();
        jLabel9 = new javax.swing.JLabel();
        btnActualizar = new javax.swing.JButton();
        btnEliminar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        txtDescripcion = new javax.swing.JTextArea();
        panelVerOdontologo = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        rbtMasculino1 = new javax.swing.JRadioButton();
        rbtFemenino1 = new javax.swing.JRadioButton();
        rbtTodos = new javax.swing.JRadioButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(204, 204, 240));

        jPanel2.setBackground(new java.awt.Color(204, 204, 240));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Mantenimiento", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tunga", 0, 18), new java.awt.Color(255, 255, 153))); // NOI18N

        btnBuscar.setText("Buscar");
        btnBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarActionPerformed(evt);
            }
        });

        comboBuscar.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Buscar por Nombre", "Buscar por Apellido Paterno", "Buscar por Apellido Materno" }));
        comboBuscar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                comboBuscarActionPerformed(evt);
            }
        });

        tblTecnico.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null, null, null, null}
            },
            new String [] {
                "Nombres", "Apellidos", "Descripción", "DNI", "Distrito", "Domicilio", "Email", "Teléfono", "Celular", "Género"
            }
        ));
        tblTecnico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tblTecnicoMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tblTecnico);

        jTabbedPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        panelOdontologo.setBackground(new java.awt.Color(204, 204, 255));

        jLabel2.setText("Apellido Paterno:");

        txtApellidoPaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtApellidoPaternoKeyPressed(evt);
            }
        });

        txtApellidoMaterno.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtApellidoMaternoKeyPressed(evt);
            }
        });

        jLabel16.setText("Apellido Materno:");

        jLabel1.setText("Nombres:");

        txtNombres.setAutoscrolls(false);
        txtNombres.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtNombresActionPerformed(evt);
            }
        });
        txtNombres.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNombresKeyPressed(evt);
            }
        });

        txtDni.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDniKeyPressed(evt);
            }
        });

        jLabel3.setText("DNI:");

        jLabel4.setText("Dirección:");

        txtDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDireccionKeyPressed(evt);
            }
        });

        jLabel5.setText("Teléfono:");

        txtTel.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtTelKeyPressed(evt);
            }
        });

        txtCelular.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCelularKeyPressed(evt);
            }
        });

        jLabel6.setText("Celular:");

        jLabel11.setText("Email:");

        txtEmail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtEmailKeyPressed(evt);
            }
        });

        txtNacionalidad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtNacionalidadKeyPressed(evt);
            }
        });

        jLabel24.setText("Nacionalidad:");

        jLabel10.setText("Descripcion:");

        jLabel8.setText("Edad:");

        jLabel7.setText("Fecha Nac:");

        jLabel15.setText("Distrito:");

        jLabel21.setText("Provincia:");

        jLabel19.setText("Departamento:");

        comboDepto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboDeptoItemStateChanged(evt);
            }
        });

        comboProvincia.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                comboProvinciaItemStateChanged(evt);
            }
        });

        comboFecha.addSelectionChangedListener(new datechooser.events.SelectionChangedListener() {
            public void onSelectionChange(datechooser.events.SelectionChangedEvent evt) {
                comboFechaOnSelectionChange(evt);
            }
        });

        txtEdad.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtEdadKeyPressed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(204, 204, 240));
        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 204)), "Género"));

        rbtMasculino.setBackground(new java.awt.Color(204, 204, 255));
        buttonGroup1.add(rbtMasculino);
        rbtMasculino.setText("Masculino");
        rbtMasculino.setActionCommand("M");

        rbtFemenino.setBackground(new java.awt.Color(204, 204, 255));
        buttonGroup1.add(rbtFemenino);
        rbtFemenino.setText("Femenino");
        rbtFemenino.setActionCommand("F");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rbtMasculino)
                .addGap(18, 18, 18)
                .addComponent(rbtFemenino)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(rbtFemenino)
                    .addComponent(rbtMasculino))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/agregarOdontologo2.png"))); // NOI18N

        btnActualizar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/update.png"))); // NOI18N
        btnActualizar.setText("Actualizar");
        btnActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnActualizarActionPerformed(evt);
            }
        });

        btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/pe/sonrisas/tools/imagenes/comun/btnEliminar.png"))); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        jButton1.setText("Registro Nuevo");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        txtDescripcion.setColumns(20);
        txtDescripcion.setRows(5);
        jScrollPane2.setViewportView(txtDescripcion);

        javax.swing.GroupLayout panelOdontologoLayout = new javax.swing.GroupLayout(panelOdontologo);
        panelOdontologo.setLayout(panelOdontologoLayout);
        panelOdontologoLayout.setHorizontalGroup(
            panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelOdontologoLayout.createSequentialGroup()
                .addGap(43, 43, 43)
                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel16)
                    .addComponent(jLabel1)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel6)
                    .addComponent(jLabel11)
                    .addComponent(jLabel24))
                .addGap(18, 18, 18)
                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelOdontologoLayout.createSequentialGroup()
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTel, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApellidoMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(51, 51, 51)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel10)
                            .addComponent(jLabel8)
                            .addComponent(jLabel7)
                            .addComponent(jLabel15)
                            .addComponent(jLabel21)
                            .addComponent(jLabel19)))
                    .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboDepto, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 105, Short.MAX_VALUE)
                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btnActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel9)))
                .addGap(67, 67, 67))
        );
        panelOdontologoLayout.setVerticalGroup(
            panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelOdontologoLayout.createSequentialGroup()
                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelOdontologoLayout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(txtApellidoPaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19)
                            .addComponent(comboDepto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelOdontologoLayout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtApellidoMaterno, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel16)))
                            .addGroup(panelOdontologoLayout.createSequentialGroup()
                                .addGap(17, 17, 17)
                                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(comboProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel21))))
                        .addGap(18, 18, 18)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15)
                            .addComponent(comboDistrito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(txtDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(comboFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(18, 18, 18)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelOdontologoLayout.createSequentialGroup()
                                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel5)
                                    .addComponent(txtTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel10))
                                .addGap(21, 21, 21)
                                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtCelular, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel6))
                                .addGap(18, 18, 18)
                                .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel11)))
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(panelOdontologoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel24)
                                .addComponent(txtNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(panelOdontologoLayout.createSequentialGroup()
                        .addGap(52, 52, 52)
                        .addComponent(jLabel9)
                        .addGap(18, 18, 18)
                        .addComponent(btnActualizar, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnEliminar)
                        .addGap(18, 18, 18)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Datos odontólogo", panelOdontologo);

        panelVerOdontologo.setBackground(new java.awt.Color(204, 204, 255));
        jTabbedPane1.addTab("Ver consultas", panelVerOdontologo);

        jPanel4.setBackground(new java.awt.Color(204, 204, 240));
        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 204)), "Género"));

        rbtMasculino1.setBackground(new java.awt.Color(204, 204, 255));
        buttonGroup2.add(rbtMasculino1);
        rbtMasculino1.setText("Masculino");
        rbtMasculino1.setActionCommand("M");

        rbtFemenino1.setBackground(new java.awt.Color(204, 204, 255));
        buttonGroup2.add(rbtFemenino1);
        rbtFemenino1.setText("Femenino");
        rbtFemenino1.setActionCommand("F");

        rbtTodos.setBackground(new java.awt.Color(204, 204, 255));
        buttonGroup2.add(rbtTodos);
        rbtTodos.setText("Todos");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(rbtTodos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbtMasculino1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(rbtFemenino1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(rbtTodos)
                    .addComponent(rbtMasculino1)
                    .addComponent(rbtFemenino1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(232, 232, 232)
                        .addComponent(txtBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(btnBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(48, 48, 48)
                        .addComponent(comboBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addGap(0, 40, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1)
                    .addComponent(jTabbedPane1))
                .addGap(26, 26, 26))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnBuscar)
                            .addComponent(txtBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(comboBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 447, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(22, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void txtNombresKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNombresKeyPressed

        if ((evt.getKeyCode() == KeyEvent.VK_ENTER)) {
            if (validar.esVacio(txtNombres.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar un nombre", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtNombres.requestFocus();
                System.out.print(validar.validarTexto(txtNombres.getText()));
            } else if (validar.validarTexto(txtNombres.getText())) {


                txtApellidoPaterno.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El nombre no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtNombres.requestFocus();
                txtNombres.selectAll();
            }
        }
    }//GEN-LAST:event_txtNombresKeyPressed

    private void txtApellidoPaternoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoPaternoKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.esVacio(txtApellidoPaterno.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar apellidos", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtApellidoPaterno.requestFocus();
            } else if (validar.validarTexto(txtApellidoPaterno.getText())) {
                txtDni.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El apellido no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtApellidoPaterno.requestFocus();
                txtApellidoPaterno.selectAll();
            }
        }
    }//GEN-LAST:event_txtApellidoPaternoKeyPressed

    private void txtDniKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDniKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtDni.getText()) && validar.validarLongitud(8, txtDni.getText())) {
                txtDireccion.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "DNI incorrecto, sólo debe contener numeros y no debe superar los 8 dígitos", "Error", JOptionPane.ERROR_MESSAGE);
                txtDni.requestFocus();
                txtDni.selectAll();
            }
        }
    }//GEN-LAST:event_txtDniKeyPressed

    private void txtDireccionKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDireccionKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER){
            if (validar.esVacio(txtDireccion.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar direccion", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtDireccion.requestFocus();
            } 
            txtTel.requestFocus();
        }
   }//GEN-LAST:event_txtDireccionKeyPressed

    private void txtTelKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtTelKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.esVacio(txtTel.getText())) {
                JOptionPane.showMessageDialog(this, "Debe ingresar telefono", "Campo obligatorio", JOptionPane.ERROR_MESSAGE);
                txtTel.requestFocus();
            } else if (validar.validarNro(txtTel.getText())) {
                txtCelular.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El teléfono sólo debe contener numeros", "Error", JOptionPane.ERROR_MESSAGE);
                txtTel.requestFocus();
                txtTel.selectAll();
            }
        }
    }//GEN-LAST:event_txtTelKeyPressed

    private void comboDeptoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboDeptoItemStateChanged
        comboProvincia.removeAllItems();
        int cod = comboDepto.getSelectedIndex() + 1;
        cargarProvincias(cod);
    }//GEN-LAST:event_comboDeptoItemStateChanged

    private void comboProvinciaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_comboProvinciaItemStateChanged
        comboDistrito.removeAllItems();
        int codD = comboDepto.getSelectedIndex() + 1;
        int codP = comboProvincia.getSelectedIndex() + 1;
         cargarDistritos(codD, codP);
    }//GEN-LAST:event_comboProvinciaItemStateChanged

    private void txtEdadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEdadKeyPressed

   }//GEN-LAST:event_txtEdadKeyPressed

    private void txtCelularKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCelularKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarNro(txtCelular.getText()) && validar.validarLongitud(9, txtCelular.getText())) {
                txtEmail.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "El celular sólo debe contener numeros y no debe superar los 9 dígitos", "Error", JOptionPane.ERROR_MESSAGE);
                txtCelular.requestFocus();
                txtCelular.selectAll();
            }
        }
    }//GEN-LAST:event_txtCelularKeyPressed

    private void txtEmailKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtEmailKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (txtEmail.getText().equals("")) {
                txtNacionalidad.requestFocus();
            } else if (validar.validarEmail(txtEmail.getText())) {
                txtNacionalidad.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "Email incorrecto", "Error", JOptionPane.ERROR_MESSAGE);
                txtEmail.requestFocus();
                txtEmail.selectAll();
            }
        }
    }//GEN-LAST:event_txtEmailKeyPressed

    private void txtNacionalidadKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtNacionalidadKeyPressed
        if (evt.getKeyCode() == evt.VK_ENTER) {
            if (validar.validarTexto(txtNacionalidad.getText())) {
                comboDepto.requestFocus();
            } else {
                JOptionPane.showMessageDialog(this, "La nacionalidad no debe contener numeros/símbolos", "Error", JOptionPane.ERROR_MESSAGE);
                txtNacionalidad.requestFocus();
                txtNacionalidad.selectAll();
            }
        }
    }//GEN-LAST:event_txtNacionalidadKeyPressed

    private void btnActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnActualizarActionPerformed
        try {
            Conexion_BD conexion = new Conexion_BD();
            
            conexion.Conectar();
            
            int codigo = Integer.parseInt(txtBusqueda.getText());
                        
            int idUbigeo = 12;
            String nombres = txtNombres.getText();
            String apellidoPaterno = txtApellidoPaterno.getText();
            String apellidoMaterno = txtApellidoMaterno.getText();
            String dni = txtDni.getText();
            String direccion = txtDireccion.getText();
            String telefono = txtTel.getText();
            String email = txtEmail.getText();
            String nacionalidad = txtNacionalidad.getText();
            String fechanac = "1990/12/21";
            char genero;
            int activo = 1;
            
            if (rbtMasculino.isSelected()) {
                    genero = rbtMasculino.getActionCommand().charAt(0);
                } else {
                    genero = rbtFemenino.getActionCommand().charAt(0);
                }
            
            conexion.insupdel("UPDATE PERSONA set nombres = '"+nombres+"', apellidoPaterno = '"+apellidoPaterno+"' apellidoMaterno = '"+apellidoMaterno+"', dni = '"+dni+"', nacionalidad = '"+nacionalidad+"', domicilio = '"+direccion+"', email = '"+email+"', telefono = '"+telefono+"', fechanac = '"+fechanac+"', genero = '"+genero+"' where idPersona ="+codigo);
            
            JOptionPane.showMessageDialog(this, "SE ACTUALIZO CORRECTAMENTE");
            
            txtBusqueda.requestFocus();
            
            try {
                conexion.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btnActualizarActionPerformed

    private void comboFechaOnSelectionChange(datechooser.events.SelectionChangedEvent evt) {//GEN-FIRST:event_comboFechaOnSelectionChange
        //txtEdad.setText("" + validar.calcularEdad(comboFecha.getText()));
    }//GEN-LAST:event_comboFechaOnSelectionChange

    private void btnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarActionPerformed
                
        limpiarTablaTecnico();
        char genero = '%';
        if (rbtMasculino1.isSelected())
            genero = 'M';
        
        if (rbtFemenino1.isSelected())
            genero = 'F';
        
        int opcionSeleccionada = comboBuscar.getSelectedIndex();
        
                
        cargarTablaTecnico(opcionSeleccionada,genero);
        
    }//GEN-LAST:event_btnBuscarActionPerformed

    private void txtNombresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtNombresActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtNombresActionPerformed

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed
        try {
            Conexion_BD conexion = new Conexion_BD();
            
            conexion.Conectar();
            
            int opcion = comboBuscar.getSelectedIndex();
            
            if (opcion==0){
                int codigo = Integer.parseInt(txtBusqueda.getText());
                conexion.insupdel("UPDATE persona SET activoPersona=0 WHERE idPersona="+codigo);
            }
            else{
                String nombre = txtBusqueda.getText();
                conexion.insupdel("UPDATE persona SET activoPersona=0 WHERE nombres='"+nombre+"'");
            }
            
                       
            JOptionPane.showMessageDialog(this, "SE ELIMINO EL REGISTRO");
            
            txtNombres.setText("");
            txtApellidoPaterno.setText("");
            txtApellidoMaterno.setText("");
            txtDni.setText("");
            txtDireccion.setText("");
            txtTel.setText("");
            txtCelular.setText("");
            txtEmail.setText("");
            txtNacionalidad.setText("");
           
           // rbtFemenino.setSelected(False);
            
            txtBusqueda.setText("");
            
            txtBusqueda.requestFocus();
            
            try {
                conexion.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnEliminarActionPerformed

    private void comboBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboBuscarActionPerformed
            
    }//GEN-LAST:event_comboBuscarActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
            frmRegistrarTecnicoDental fr= new frmRegistrarTecnicoDental();
            
            fr.setVisible(true);
            
    }//GEN-LAST:event_jButton1ActionPerformed

    private void txtApellidoMaternoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtApellidoMaternoKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtApellidoMaternoKeyPressed

    private void tblTecnicoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblTecnicoMouseClicked
        int fila = tblTecnico.getSelectedRow();
            
        if(fila != -1){
                
            String nombres      = listado.get(fila).get(0).toString();
            String apePaterno   = listado.get(fila).get(1).toString();
            String apeMaterno   = listado.get(fila).get(2).toString();
            String descripcion  = listado.get(fila).get(3).toString();
            String dni	        = listado.get(fila).get(4).toString();
            String distrito     = listado.get(fila).get(5).toString();
            String domicilio    = listado.get(fila).get(6).toString();
            String email	= listado.get(fila).get(7).toString();
            String telefono     = listado.get(fila).get(8).toString();        
            String celular      = listado.get(fila).get(9).toString();
            String genero	= listado.get(fila).get(10).toString();
            String nacionalidad = listado.get(fila).get(11).toString();
                  
                
            //Pasamos los datos a las cajas de texto
                        
            txtNombres.setText(nombres);
            txtApellidoPaterno.setText(apePaterno);
            txtApellidoMaterno.setText(apeMaterno);
            txtDescripcion.setText(descripcion);
            txtDni.setText(dni);
           // txtDistrito.setText(distrito);
            txtDireccion.setText(domicilio);
            txtEmail.setText(email);
            txtTel.setText(telefono);
            txtCelular.setText(celular);
            txtNacionalidad.setText(nacionalidad);
            
//             if (genero.equals('M'))
//                rbtMasculino.setSelected(true);
//             else
//                rbtFemenino.setSelected(true);
                  
            }
        
            else{
                JOptionPane.showMessageDialog(this, "Seleccione el tecnico que desea editar");
            }
        
    }//GEN-LAST:event_tblTecnicoMouseClicked

    private void cargarTablaTecnico(int opcion,char genero) {
        try {
            Conexion_BD conexion = new Conexion_BD();
            ResultSet rs = null;
            conexion.Conectar();
             String query = "SELECT p.nombres,p.apellidoPaterno,p.apellidoMaterno,t.desctrabajo,p.dni,u.nombre,p.domicilio,p.email,p.telefono,p.celular,p.genero,p.nacionalidad,p.fechanac,u.coddepto,u.codprov,u.coddist FROM tecnicodental t,persona p , ubigeo u WHERE t.idPERSONA = p.idPERSONA AND p.idUbigeo = u.idUbigeo AND p.genero like'"+genero+"'";
             String busqueda = txtBusqueda.getText();
             
             switch(opcion){
                 case 0: query += " AND p.nombres like '"+busqueda+"%'";break;
                 case 1: query += " AND p.apellidoPaterno like '"+busqueda+"%'";break;
                 case 2: query += " AND p.apellidoMaterno like '"+busqueda+"%'";break;    
             
             }
             System.out.println(query);
             
             
             rs = conexion.Consultar(query);
             
                          
             int fila = 0;
             while(rs.next()){
                    
                 
                 ArrayList<Object> registro = new ArrayList<Object>();
                    // PARAMETROS (dato a ingresar, fila, y columna)
                    // Columna se inicia en 0
                tblTecnico.setValueAt(rs.getString(1), fila, 0);
                tblTecnico.setValueAt(rs.getString(2)+" "+rs.getString(3), fila, 1);
                tblTecnico.setValueAt(rs.getString(4), fila, 2);
                tblTecnico.setValueAt(rs.getString(5), fila, 3);
                tblTecnico.setValueAt(rs.getString(6), fila, 4);
                tblTecnico.setValueAt(rs.getString(7), fila, 5);
                tblTecnico.setValueAt(rs.getString(8), fila, 6);
                tblTecnico.setValueAt(rs.getString(9), fila, 7);
                tblTecnico.setValueAt(rs.getString(10), fila, 8);
                tblTecnico.setValueAt(rs.getString(11), fila, 9);
                
                registro.add(rs.getString(1));
                registro.add(rs.getString(2));
                registro.add(rs.getString(3));
                registro.add(rs.getString(4));
                registro.add(rs.getString(5));
                registro.add(rs.getString(6));
                registro.add(rs.getString(7));
                registro.add(rs.getString(8));
                registro.add(rs.getString(9));
                registro.add(rs.getString(10));
                registro.add(rs.getString(11));
                registro.add(rs.getString(12));
                registro.add(rs.getString(13));
                registro.add(rs.getString(14));
                registro.add(rs.getString(15));
                registro.add(rs.getString(16));
                registro.add(rs.getString(17));
                listado.add(registro);
                
                fila++;
            }   
             
            JOptionPane.showMessageDialog(this, listado.size());
            
            try {
                conexion.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmEditarPersona.class.getName()).log(Level.SEVERE, null, ex);
            }
            rs.close();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(frmEditarPersona.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmEditarPersona.class.getName()).log(Level.SEVERE, null, ex);
        }
    
    }
    
    private void cargarDepartamentos() {
        try {
            Conexion_BD conexion = new Conexion_BD();
            
            conexion.Conectar();
            
            ResultSet datos = null; // ResultSet guarda la consulta en memoria
            
            datos = conexion.Consultar("SELECT idUbigeo,nombre FROM ubigeo where codprov = 0 and coddist = 0");
            
            while(datos.next()){
                comboDepto.addItem(datos.getString("nombre"));      
            }
                        
            conexion.Desconectar();
            datos.close();
            
        } catch (Exception ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        } 
            
        
    }
    
    private void cargarProvincias(int codigo) {
        try {
            Conexion_BD conexion = new Conexion_BD();
            
            conexion.Conectar();
            
            ResultSet datos = null;
            
            datos = conexion.Consultar("select idUbigeo,nombre from ubigeo where coddist = 0 and codprov <> 0 and coddepto ="+codigo);
            
            while(datos.next()){
                comboProvincia.addItem(datos.getString("nombre"));
            }
            try {
                conexion.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
            }
            datos.close();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void cargarDistritos(int depto,int provincia) {
        try {
            Conexion_BD conexion = new Conexion_BD();
            
            conexion.Conectar();
            
            ResultSet datos = null;
            
            datos = conexion.Consultar("SELECT idUbigeo,nombre FROM UBIGEO where coddepto = "+depto+" and codprov = "+provincia+" and coddist <> 0");
            
            while(datos.next()){
                comboDistrito.addItem(datos.getString("nombre"));
            }
            try {
                conexion.Desconectar();
            } catch (Exception ex) {
                Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
            }
            datos.close();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void limpiarTablaTecnico() {
        int fila = 0;
            
        while (fila < tblTecnico.getRowCount()){
        
                tblTecnico.setValueAt("", fila, 0);
                tblTecnico.setValueAt("", fila, 1);
                tblTecnico.setValueAt("", fila, 2);
                tblTecnico.setValueAt("", fila, 3);
                tblTecnico.setValueAt("", fila, 4);
                tblTecnico.setValueAt("", fila, 5);
                tblTecnico.setValueAt("", fila, 6);
                tblTecnico.setValueAt("", fila, 7);
                tblTecnico.setValueAt("", fila, 8);
                tblTecnico.setValueAt("", fila, 9);
                fila++;
        }
    }
    
    
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(frmMantenerTecnicoDental.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new frmMantenerTecnicoDental().setVisible(true);
                
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnActualizar;
    private javax.swing.JButton btnBuscar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JComboBox comboBuscar;
    private javax.swing.JComboBox comboDepto;
    private javax.swing.JComboBox comboDistrito;
    private datechooser.beans.DateChooserCombo comboFecha;
    private javax.swing.JComboBox comboProvincia;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel panelOdontologo;
    private javax.swing.JTabbedPane panelVerOdontologo;
    private javax.swing.JRadioButton rbtFemenino;
    private javax.swing.JRadioButton rbtFemenino1;
    private javax.swing.JRadioButton rbtMasculino;
    private javax.swing.JRadioButton rbtMasculino1;
    private javax.swing.JRadioButton rbtTodos;
    private javax.swing.JTable tblTecnico;
    private javax.swing.JTextField txtApellidoMaterno;
    private javax.swing.JTextField txtApellidoPaterno;
    private javax.swing.JTextField txtBusqueda;
    private javax.swing.JTextField txtCelular;
    private javax.swing.JTextArea txtDescripcion;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtDni;
    private javax.swing.JTextField txtEdad;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtNacionalidad;
    private javax.swing.JTextField txtNombres;
    private javax.swing.JTextField txtTel;
    // End of variables declaration//GEN-END:variables

      

    
}
